package com.chushouya.order.constants;

import com.general.framework.core.enums.IEnum;
import com.general.framework.core.lang.Strings;

import java.util.Objects;

/**
 * 付款方式枚举
 */
public enum PaymentMethodEnum implements IEnum<Integer> {

    ONLINE_ALIPAY(1, "在线支付宝付款"),
    OFFLINE_PAYMENT(2, "线下收款");

    private Integer value;

    private String desc;

    PaymentMethodEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String getDesc(Integer value) {
        for (PaymentMethodEnum thisEnum : PaymentMethodEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum.desc;
            }
        }
        return Strings.EMPTY;
    }

    public static PaymentMethodEnum get(Integer value) {
        for (PaymentMethodEnum thisEnum : PaymentMethodEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum;
            }
        }
        return null;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.desc;
    }
}
